﻿using CloudStorage_Backend.model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace CloudStorage_Backend.dao
{
    public class UserDao
    {
        private readonly UserContext userContext;

        public UserDao(UserContext userContext)
        {
            this.userContext = userContext;
        }

        public User FindUserByName(string userName)
        {
            return userContext.Users.FirstOrDefault(u => u.UserName == userName);
        }

        public User AddUser(User user)
        {
            userContext.Add(user);
            userContext.SaveChanges();
            return user;
        }
    }
}
